package com.train.webadmin.app.model;

import com.baomidou.mybatisplus.annotation.*;
import com.train.common.core.util.MyCommonUtil;
import com.train.common.core.annotation.*;
import com.train.webadmin.app.vo.ScoreVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * 班级信息实体对象。
 *
 * @author xulei
 * @date 2025-03-07
 */
@Data
@TableName(value = "class_info")
public class ClassInfo {

    /**
     * id。
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 班级code。
     */
    @TableField(value = "code")
    private String code;

    /**
     * 班级名称。
     */
    @TableField(value = "class_name")
    private String className;

    /**
     * 班级期数。
     */
    @TableField(value = "class_periods")
    private String classPeriods;

    /**
     * 创造时间。
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 班主任id。
     */
    @TableField(value = "teacher_id")
    private Long teacherId;

    /**
     * 修改时间。
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 修改用户id。
     */
    @TableField(value = "update_user_id")
    private Long updateUserId;

    /**
     * 创建用户id。
     */
    @TableField(value = "create_user_id")
    private Long createUserId;

    /**
     * 逻辑删除标记字段(1: 正常 -1: 已删除)。
     */
    @TableLogic
    @TableField(value = "deleted_flag")
    private Integer deletedFlag;

    /**
     * code / class_name / class_periods LIKE搜索字符串。
     */
    @TableField(exist = false)
    private String searchString;

    public void setSearchString(String searchString) {
        this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
    }

    @RelationOneToOne(
            masterIdField = "teacherId",
            slaveModelClass = TeacherInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TeacherInfo teacherInfo;

    @TableField(exist = false)
    private Double score;

    @TableField(exist = false)
    private List<StudentInfo> studentInfos;

    @TableField(exist = false)
    private List<CourseInfo> courseInfos;

    @TableField(exist = false)
    private List<TPaperInfo> tPaperInfos;

    @TableField(exist = false)
    private ScoreVo scoreVo;

    @TableField(value = "start_time")
    private Date startTime;

    @TableField(value = "end_time")
    private Date endTime;
}
